feat(tracing): add DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT#3997
feat(tracing): add DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT#3997MilanGarnier wants to merge 11 commits into
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: c7674bd | Docs | Datadog PR Page | Give us feedback! |
Adds the new `DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT` config key (values: continue, restart, ignore) with a CUSTOM(INT) parser, the corresponding C enum, and the supported-configurations.json entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds three behaviors at the single extraction chokepoint (ddtrace_apply_distributed_tracing_result): - continue (default): inherit upstream trace context unchanged - restart: start a fresh trace; upstream captured as a span link with reason=propagation_behavior_extract. When the root span doesn't exist yet at request-init time, the link is queued in DDTRACE_G(pending_upstream_span_link) and attached in ddtrace_open_span. - ignore: drop all extracted context including baggage and sampling priority Also extracts ddtrace_build_span_link_from_result() from the SpanLink fromHeaders method so it can be reused by the restart path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers the three behaviors (continue, restart, ignore) and config parsing (case-insensitive values, invalid value falls back to default). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6b7e259 to
3ca8428
Compare
|
|
||
| if (behavior == DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT_RESTART && (result->trace_id.low || result->trace_id.high)) { | ||
| // behavior=restart: zero trace_id so a fresh trace starts; upstream captured as span link | ||
| // drop _dd.p.* first so the builder does not include them in link attributes |
There was a problem hiding this comment.
Why would we want to drop e.g. _dd.p.usr.id? Shouldn't that be an useful attribute to see?
There was a problem hiding this comment.
As far as I understand it, the role of this feature is to explicitly discard all incoming tags other than baggage. That way, let's say it is a service extracting a trace coming from outside, it can decide to restart a trace in its own terms (own sampling decision and everything else). That being said, I am new on the subject so I'll look again in other tracers
There was a problem hiding this comment.
But, if it's only baggage what you want, you only need result->baggage (which is handled below for you) and ignore result->meta_tags completely (simply clean), which are the tracer tags, like x-datadog-tags and tracestate equivalent.
| } | ||
| ddtrace_build_span_link_from_result(&result, link); | ||
|
|
||
| result.meta_tags.pDestructor = NULL; // we moved values directly |
There was a problem hiding this comment.
You did not like the do-not-touch-the-refcount approach? :-) Seeing you susbtituted it for zval_add_ref copying.
Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
Summary
Implements
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT(APMAPI-1941, feature-parity #353) for the PHP tracer, matching behavior already present in .NET, Python, Node, Java, Ruby, and Rust.Three values:
continue(default): inherit upstream trace context unchanged — no behavior changerestart: start a fresh trace; the upstream context is captured as a span link withreason=propagation_behavior_extractignore: drop all extracted context including baggage and sampling priorityDesign:
ddtrace_apply_distributed_tracing_resultindistributed_tracing_headers.c, covering both request-init andconsume_distributed_tracing_headersuserland callsrestartpath: when the root span doesn't yet exist at request-init time, the span link is queued inDDTRACE_G(pending_upstream_span_link)and consumed inddtrace_open_spanwhen the root span is createdddtrace_build_span_link_from_result()fromSpanLink::fromHeadersfor reuseTest plan
tests/ext/distributed_tracing/propagation_behavior_extract_continue.phpt— verifies trace_id inherited, no span link, baggage preservedtests/ext/distributed_tracing/propagation_behavior_extract_restart.phpt— verifies fresh trace_id, span link with correct upstream ids and reason, baggage preserved,_dd.p.*not in link attributestests/ext/distributed_tracing/propagation_behavior_extract_ignore.phpt— verifies fresh trace_id, no span link, baggage dropped, sampling priority droppedtests/ext/distributed_tracing/propagation_behavior_extract_config.phpt— verifies case-insensitive parsing, invalid value falls back tocontinueRelated
🤖 Generated with Claude Code